<style lang="less">
@import "../../../styles/common.less";
@import "../../../styles/table.less";
</style>

<template>
    <div>
      <Card class="clearfix" style="padding-bottom: 16px">
        <p slot="title">
          数据列表
        </p>
        <!--<Form label-position="left" :label-width="72">
          <Row :gutter="15">
            <i-col span="6">
              <FormItem label="类型名称：">
                <Input v-model="dataValue" placeholder="请输入类型名称"/>
              </FormItem>
            </i-col>
            <i-col span="6">
              <Button type="success" @click="searchData" icon="ios-search" >搜索</Button>
            </i-col>
          </Row>
        </Form>-->
        <div class="btn-group-list">
          <Button  @click="addData" v-if="access.add" icon="ios-checkmark" style="width:90px;" type="primary">新增</Button>
        </div>
        <br>
        <div>
            <list-table refs="table1" v-model="tableData" :access="access" :table-data="tableData"></list-table>
        </div>
        <Page ref="pages" :total="itemTotal" show-total style="float: right; margin-top: 20px" @on-change="getList"></Page>
      </Card>
    </div>
</template>

<script>
import listTable from './components/datalistTable.vue'
import ajax from '../../../libs/axios.js'
export default {
    name: 'dicdataindex',
    components: {
        listTable
    },
    data () {
        return {
          kezu_testModelShow:false,
           dataValue: '',
           typeId:'',
           access:{
                edit: true, //控制编辑按钮显示
                func: true,
                remove: true,
                add: true
            },
            loginName: '',//用户名称
            itemTotal: 0,
            tableData: []
        }
    },
    methods: {
        init () {
           this.$store.commit('setActiveName', 'dictypeindex');
           var typeId = this.$route.params.id;
           this.typeId = typeId;
           this.getList(1)
        },
        addData () {
          this.kezu_testModelShow = true;
            let argu = {
                id: this.typeId
            }
            this.$router.push({
                name: 'adddicdata',
                params: argu
            })
        },
        searchData () {
            this.getList(1)
        },
        getList (page) {
            let _that = this;
            let url = 'adminlogin/dic/selectDicDataInfos'
            let data = {
                dataValue: this.dataValue,
                typeId:this.typeId,
                pageSize: 10,
                pageNum: page
            }
            ajax.formRes(url, data).then(res => {
                _that.tableData = res.data;
                _that.itemTotal = res.count;
            })
                .catch(res => {
                    console.log('有错误信息')
                    // fail
                })
        }
    },
    mounted () {
        this.init()
    },
    activated() {
      this.init()
    },
}
</script>
